/*******************************************************************************
  Name: gdt.h
  Copyright: Kieran Foot 2009
  Author: Kieran Foot
  Date: 12/06/09 12:38
  Description: GDT Header file
*******************************************************************************/

#ifndef __GDT_H__
#define __GDT_H__

#include <_ansi.h>

_BEGIN_STD_C

//-------------------------//
// Imported from GDT_A.ASM //
//-------------------------//
extern void gdt_flush();

//----------------------//
// Functions from GDT.C //
//----------------------//
void gdt_set_gate(int num, unsigned long BASE, unsigned long LIMIT, unsigned char CODE, unsigned char DPL, unsigned char RW);

//---------------------------//
// Structure for a GDT entry //
//---------------------------//
struct gdt_entry {
	unsigned int limit_low:16;
	unsigned int base_low : 24;
	unsigned int accessed :1;
	unsigned int read_write :1;
	unsigned int conforming_expand_down :1;
	unsigned int code :1;
	unsigned int always_1 :1;
	unsigned int DPL :2;
	unsigned int present :1;
	unsigned int limit_high :4;
	unsigned int available :1;
	unsigned int always_0 :1;
	unsigned int big :1;
	unsigned int gran :1;
	unsigned int base_high :8;
} __attribute__((packed));

//-------------------------------//
// Structure for the GDT pointer //
//-------------------------------//
struct gdt_pointer {
    unsigned short limit;
    unsigned int base;
} __attribute__((packed));

_END_STD_C

#endif
